package org.microboot.data.xa.config;

import org.microboot.core.constant.Constant;
import org.microboot.data.factory.DataSourceFactory;
import org.microboot.data.xa.factory.DruidXADataSourceFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
 * @author 胡鹏
 */
@Configuration
@DependsOn(Constant.APPLICATION_CONTEXT_HOLDER)
public class XADataConfig {

    /**
     * 初始化DataSourceFactory（分布式事务）
     *
     * 覆盖原本默认的DataSourceFactory
     *
     * @return
     */
    @Bean(name = "org.microboot.data.factory.DataSourceFactory")
    public DataSourceFactory initDataSourceFactory() {
        return new DruidXADataSourceFactory();
    }
}